<template>
  <div class="page" data-name="mapSearch" >
    <!-- Top Navbar-->
    <div class="navbar">
      <div class="navbar-inner" style="background-color: #3ec889">
        <div class="left">
          <a href="#" class="link back" id="text-back">
            <i class="icon icon-back"></i>
            <span class="ios-only">返回</span>
          </a>
        </div>
        <div class="title" id="r-result-input" style="margin-left: 10px;width: 380px">
          <input type="search" name="name" placeholder="搜索地点" style="width: 380px">
        </div>
        <!--<div class="right">-->
          <!--<a href="#"  id="textMapSure">-->
            <!--<i class="icon another-icon" >确定</i>-->
          <!--</a>-->
        <!--</div>-->
      </div>
    </div>
    <div class="page-content infinite-scroll-content" id="text-map" >
      <div class="list" id="text-map-list" style="margin-top: 0px">
        <ul></ul>
      </div>
      <div class="preloader infinite-scroll-preloader"></div>
    </div>
  </div>
</template>
<script>
  return {
    on:{
      pageBeforeIn:function (e, page) {
        $$('.infinite-scroll-preloader').hide();
      },
      pageInit: function(e, page) {
        var allowInfinite = true;
        var searchText = undefined;
        var self = this;

        $$('#text-back').on('click',function () {
          window.isSaveTextAdr = false;
          self.$router.back("/baiduMap/");
        });

        $('#r-result-input').bind('input propertychange', function () {
          $$('.infinite-scroll-preloader').show();
          searchText = $$(" input[ type='search' ] ").val();
          $$('#text-map-list ul').html("");
          doTextSch(searchText, window.locationAdr.city, 1, 20,self.$router);
        });

        //分页加载结果
        $$('.infinite-scroll-content').on('infinite', function () {

          if (!allowInfinite) return;
          allowInfinite = false;

          setTimeout(function () {
            allowInfinite = true;

            doTextSch(searchText, window.locationAdr.city, undefined, self.$router);

          }, 1000);
        });
      }
    }
  }
</script>
